package com.zsx.dao.imp;
import com.zsx.dao.FindAdmin;
import com.zsx.entities.Admin;
import com.zsx.utils.C3p0Util;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.LinkedList;
import java.util.List;
public class ImpFindAdmin implements FindAdmin {
    @Override
    public List<Admin> admins() {
        List<Admin> list=new LinkedList<>();
        Statement statement = C3p0Util.getStatement();
        try {
            ResultSet resultSet = statement.executeQuery("select * from admin");
            while (resultSet.next()) {
                int id = resultSet.getInt("id");
                int password = resultSet.getInt("password");
                Admin admin=new Admin(id,password);
                list.add(admin);
            }
            return list;
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally{
            C3p0Util.close();
        }
        return null;
    }
}
